﻿@page "/tree-grid/batch-editing"

@using Syncfusion.Blazor.TreeGrid;
@*Hidden:Lines*@
@using ej2_blazor_wrapdata
@inherits SampleBaseComponent;
@*End:Hidden*@

<SampleDescription>
    <p>This sample demonstrates the Batch Editing.</p>
</SampleDescription>
<ActionDescription>
   <p>The Tree Grid supports CRUD operations. This CRUD operations can be configured in Tree Grid using <code>TreeGridEditSettings</code>. Also, it has different modes to manipulate the datasource.</p>
   <p> The available modes are,</p>
      <ul><li><code>EditMode.Row</code></li>
          <li><code>EditMode.Cell</code></li>
          <li><code>EditMode.Dialog</code></li>
          <li><code>EditMode.Batch</code></li>
      </ul>
    <p> In this demo, Batch mode is enabled for editing by defining <code>Mode</code> as <code>EditMode.Batch</code> with <code>NewRowPosition</code> as <code>RowPosition.Below</code>. You can start editing by double clicking a cell and can change the cell value. The edited cell will be highlighted while
        navigating to a new cell, so that you know which cells had been edited. You can bulk save the edited data to the datasource by clicking on the toolbar's update button.</p>
    <p>More information on the batch editing can be found in this <a target='_blank' href='https://blazor.syncfusion.com/documentation/treegrid/edit/#batch'>documentation section</a>.</p>
</ActionDescription>


<div class="col-lg-12 control-section">
    <div class="content-wrapper">
        <div class="row">
            <SfTreeGrid DataSource="@TreeData" IdMapping="TaskId" ParentIdMapping="ParentId" Height="315" TreeColumnIndex="1" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
                <TreeGridPageSettings PageSize="2"></TreeGridPageSettings>
                <TreeGridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></TreeGridEditSettings>
                <TreeGridColumns>
                    <TreeGridColumn Field="TaskId" HeaderText="Task ID" Width="60" IsPrimaryKey="true" ValidationRules="@(new Syncfusion.Blazor.Grids.ValidationRules() { Required=true})" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn>
                    <TreeGridColumn Field="TaskName" HeaderText="Task Name" ValidationRules="@(new Syncfusion.Blazor.Grids.ValidationRules() { Required=true})" Width="180"></TreeGridColumn>
                    <TreeGridColumn Field="StartDate" HeaderText="Start Date" Format="d" Type=Syncfusion.Blazor.Grids.ColumnType.Date Width="85" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" EditType=Syncfusion.Blazor.Grids.EditType.DatePickerEdit></TreeGridColumn>
                    <TreeGridColumn Field="Duration" HeaderText="Duration" Width="100" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn>
                    <TreeGridColumn Field="Progress" HeaderText="Progress" Width="100"></TreeGridColumn>
                    <TreeGridColumn Field="Priority" HeaderText="Priority" Width="80" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn>
                </TreeGridColumns>
            </SfTreeGrid>
        </div>
    </div>
</div>


@code{


    public List<WrapData> TreeData { get; set; }

    protected override void OnInitialized()
    {
        this.TreeData = WrapData.GetWrapData().ToList();
    }

}
